package com.education.service.edu.controller.admin;

import com.education.result.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

/**
 * 登录控制器
 * Created by Lance on 2020/06/22 9:31
 */
@Api(tags = "登录")
@Slf4j
@RestController
@RequestMapping("/user")
public class LoginController {

    /**
     * 登录
     * @return
     */
    @PostMapping("login")
    public R login(){
        return R.ok().data("token", "admin");
    }

    /**
     * 登录成功携带 token 获取用户信息
     * @return
     */
    @GetMapping("info")
    public R info(){
        return R.ok().data("name", "lance")
                .data("roles", "[student]")
                .data("avatar", "https://online-education-lance.oss-cn-beijing.aliyuncs.com/login/header.jpg");
    }

    /**
     * 退出
     * @return
     */
    @PostMapping("logout")
    public R logout(){
        return R.ok();
    }
}
